A nonvolatile memory (for example, an EEPROM or a flash memory) has been conventionally utilized as a memory which is capable of retaining stored contents even when power supply is cut off and, in addition, which is capable of electrically rewriting the stored content (see, for example, Japanese Patent Laid-Open No. Hei 8-287697). In the nonvolatile memory, due to its properties, even when a part of the data (for example, several bytes of 16 bytes) is to be updated, it is required to rewrite the entire block of data (that is, all 16 bytes). In other words, one entire block in a nonvolatile memory is temporarily copied in a RAM and, after a part of data in the block is rewritten on a RAM, the entire block where rewriting has been finished is rewritten in the nonvolatile memory. In this case, since validity of data in each of the block units is required to control when the block unit has been rewritten, in order to recognize whether data are correctly rewritten or not, error detection data such as CRC or BCC are commonly written into the block simultaneously.
Systems have been known in which a high-order device or a host device such as an ATM sends an execution command for processing to a low-order device such as a card reader, which receives the command, executes the processing and notifies its processing result to the high-order device. In this system, the low-order device is provided with a nonvolatile memory which retains data for setting various functional operations in the low-order device such as a number of times of ejection retry and a number of times of magnetic read retry. The low-order device is structured to execute the respective functional operations on the basis of the data. The high-order device is provided with commands for writing data (data updating command) for setting various functional operations of the low-order device into the nonvolatile memory.
In the system described above, when the low-order device receives a command for updating certain data in the nonvolatile memory from the high-order (host) device, an entire block including the corresponding data is developed (or read out) on a RAM in order to update corresponding data in the nonvolatile memory and an error detection data of the block is checked. At this time, there may be a case when the error detection data of the block is detected as an error and data in the block may be damaged by a certain cause. However, it cannot be judged which data are damaged in the block.
In the situation described above, for example, in a case that only data to be updated are overwritten (rewritten) in the block which is read out from the nonvolatile memory and, after the error detection data are also recalculated and updated (rewritten) on the basis of the block after having been updated, the entire block after having been rewritten is overwritten at the original position in the nonvolatile memory, there may cause a malfunction in the low-order device. In other words, when data except a part of the data to be updated were damaged to cause an error, the error data are regarded as a correct value and are written into the nonvolatile memory. For example, although data of 4-times are a correct value, error data of 20-times are regarded as a correct value which was written into the nonvolatile memory. In addition, the error detection data are also calculated based on the value and are rewritten into the nonvolatile memory. Therefore, a function which is operated on the basis of the data (for example, ejection retry or magnetic read retry) will be operated on the basis of the error data (for example, error data of 20-times). Therefore, in the worst case, there is a possibility that an object to be treated in the low-order device may be damaged. For example, 4-times of ejection retry does not cause a problem but, when an ejection retry is executed 20-times, card deterioration due to abrasion may occur.
In order to prevent this problem, a conventional system has been commonly structured in which, when error detection data of a block developed on a RAM are detected as an error, all data of the block are rewritten to initial values (default value such as a shipping value or standard value) and a notice of having detected with an error at the time of data updating is sent to the high-order device to request so as to update all data in the corresponding block.
However, the conventional system as described above has following problems.
First, the host device which has received a notice of error with respect to a data writing command to be requested updating of all data of the corresponding block so as to be rewritten to initial values is required to immediately update data of the corresponding block to the initial values. For example, when a system operation is continued with data of the initial value as they are without immediately updating data of the corresponding block (without updating data of the initial value to original proper data), a function being operated on the basis of data in the corresponding block will be operated on the basis of the data of the initial value. As an example, although the value of 4-times is an original correct value but the function is operated on the basis of the initial value, i.e., 2-times. In this case, it may not cause a serious malfunction but an operation has been continued in a state which is different from an originally expected operation, for example, in a state where the number of times of retry is 2-times instead of 4-times. As a result, the system may be deteriorated in a low reliability such that an unanticipated error is notified to the high-order device. For example, in a system which is structured such that the high-order device is originally to be notified with an error through 4-times retry, an error is notified to the high-order device when a retry is performed only two times based on the initial value. Therefore, as described above, data of the corresponding block have to be updated to original data immediately, but actually, there are some high-order devices which are unable to operate in such a rapid manner.
Further, even when the high-order device is capable of immediately updating data of the corresponding block to the original data, in a case that the updating operation is suspended due to a trouble (system down, for example) while data of the corresponding block are being updated by respective commands one by one, an error cannot be detected when respective functions are executed because the error detection data have been normally and correctly written, in other words, the error detection data are recalculated and updated whenever the respective data of the corresponding block are updated by respective commands one by one. Accordingly, there is no means for recognizing that the data had been on the way of being updated. Under the state as described above, although functions being operated with the initial values without having been updated and functions being correctly operated with data after having been updated are coexisted with each other, operations are continued. As a result, similarly to the above-mentioned case, reliability of the system may be reduced until the data of the corresponding block are updated to the original data, or an unanticipated error may be informed to the high-order device.